import jsonp from 'common/js/jsonp'
import {commonParams, options} from './config'
import axios from 'axios'

export function getRecommend() { //获取首页的轮播图 XHR JS
  const url = 'https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg'

  const data = Object.assign({}, commonParams, { //系统公共的参数
    platform: 'h5',
    uin: 0,
    needNewCode: 1
  })

  return jsonp(url, data, options)
}

// ajax请求,不是jsonp请求了
export function getDiscList() {
  const url = '/api/getDiscList'
  const data = Object.assign({}, commonParams, {
    platform: 'yqq',
    hostUin: 0,
    sin: 0,
    ein: 29,
    sortId: 5,
    needNewCode: 0,
    categoryId: 10000000,
    rnd: Math.random(),
    format: 'json'
  })
  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}


export function getSongList(disstid) {
// const url = '/api/getDiscList'
// const url = 'https://c.y.qq.com/mv/fcgi-bin/getmv_by_tag?'
const url = 'https://c.y.qq.com/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg'
// const url = 'https://y.gtimg.cn/c/=/music/portal/js/common/map.js,/music/portal/js/common/music/mod.js'

const data = Object.assign({}, commonParams, {
 disstid,
 type: 1,
 json: 1,
 utf8: 1,
 onlysong: 0,
 format: jsonp,
 platform: 'yqq',
 hostUin: 0,
 needNewCode: 0,
 g_tk: 5381,

})

return jsonp(url, data, options)
}